package app.champaign;

public class UniquePathsWithObstacles{
    public static void main(String[] args) {
        
    }

    public static int uniquePathsWithObstacles(int[][] obstacleGrid) {
        int[][] f = new int[obstacleGrid.length][obstacleGrid[0].length];
        for(int i = 0; i < obstacleGrid.length; i++){
            for(int j = 0; j < obstacleGrid[0].length; j++){
                if(obstacleGrid[i][j] ==1){
                    continue;
                }
                if( i == 0 || j == 0) {
                    f[i][j] = 1;
                }else{
                    f[i][j] = f[i -1][j] + f[i][j-1];
                }
                
            }
        }
        return f[obstacleGrid.length][obstacleGrid[0].length];
        
    }
}